home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / video / fly8111-.000 / fly8111- / fly8 / plane.h < prev    next >
C/C++ Source or Header  |  1979-12-31  |  14KB  |  445 lines

  1. /* --------------------------------- plane.h -------------------------------- */
  2.  
  3. /* This is part of the flight simulator 'fly8'.
  4.  * Author: Eyal Lebedinsky (eyal@ise.canberra.edu.au).
  5. */
  6.  
  7. /* Common header for plane dynamics models.
  8. */
  9.  
  10. #ifndef FLY8_PLANE
  11. #define FLY8_PLANE
  12.  
  13. #include "hud.h"
  14.  
  15. typedef struct btrail    BTRAIL;
  16. struct btrail {
  17.     BTRAIL        *next;
  18.     LVECT        R;
  19.     VECT        V;
  20.     Uint        ms;
  21. };
  22.  
  23. typedef struct e_plane E_PLANE;
  24. struct e_plane {
  25.     struct e_parms    *parms;        /* plane parameters */
  26.     void        *private;    /* private model data */
  27.     Ushort    flags;
  28. #define    PF_AUTO        0x0001
  29. #define    PF_ONGROUND    0x0002
  30. #define PF_CHASE    0x0004
  31. #define PF_KILL        0x0008
  32. #define PF_FLAMEOUT    0x0010
  33. #define PF_GLIMIT    0x0020
  34. #define PF_STALL    0x0040
  35. #define PF_AUTOFLAP    0x0080
  36. #define PF_AUTORUDDER    0x0100
  37. #define PF_AUTOELEVATOR    0x0200
  38. #define PF_NOSTALL    0x0400
  39. #define PF_LIMITED    0x0800
  40.     Ushort    hud;
  41. #define    HUD_ON        0x0001
  42. #define    HUD_LADDER    0x0002
  43. #define    HUD_BIG        0x0004
  44. #define    HUD_FINE    0x0008
  45. #define    HUD_XFINE    0x0010
  46. #define    HUD_PLUS    0x0020
  47. #define    HUD_CURSOR    0x0040
  48. #define    HUD_VV        0x0080
  49. #define    HUD_TARGET    0x0100
  50. #define    HUD_DATA    0x0200
  51. #define    HUD_RETICLE    0x0400
  52. #define    HUD_ROSS    0x0800
  53. #define    HUD_INFO    0x1000
  54. #define    HUD_INFOM    0x7000
  55. #define    HUD_DEFAULT    (HUD_TARGET|HUD_RETICLE)
  56. #define    HUD_FULLHEADING    0x8000
  57.     Ushort    hud1;
  58. #define    HUD_TOP        0x0001
  59. #define    HUD_LIMIT    0x0002
  60. #define    HUD_CORNER    0x0004
  61. #define    HUD_AALARM    0x0008
  62. #define    HUD_VALARM    0x0010
  63. #define    HUD_KNOTS    0x0020
  64. #define    HUD_PANEL    0x0040
  65. #define    HUD_ACCVECT    0x0080
  66. #define    HUD_TYPE    0x0100
  67. #define    HUD_TYPES    0x0700
  68. #define    HUD_CLASSIC    (0*HUD_TYPE)
  69. #define    HUD_FA18    (1*HUD_TYPE)
  70. #define    HUD_F16        (2*HUD_TYPE)
  71. #define    HUD_F15        (3*HUD_TYPE)
  72. #define    HUD_ETHER    (4*HUD_TYPE)
  73. #define    HUD_FLIR    (5*HUD_TYPE)
  74. #define    HUD_PENDULUM    0x0800
  75. #define    HUD_INAME    0x1000
  76. #define    HUD_IDIST    0x2000
  77. #define    HUD_THICK    0x4000
  78. #define    HUD_BORDER    0x8000
  79.     Ushort    hud2;
  80. #define    HUD_ILS        0x0001
  81. #define    HUD_VW         0x0002
  82. #define    HUD_ALTITUDE    0x0004
  83. #define    HUD_SPEED    0x0008
  84. #define    HUD_HEADING    0x0010
  85. #define HUD_REALHEADING    0x0020        /* show real heding scale */
  86. #define    HUD_HIDETGT    0x0040
  87. #define    HUD_BETA    0x0080
  88. #define HUD_XBREAK    0x0100
  89. #define HUD_XGRID    0x0200
  90. #define HUD_DIRECTOR    0x0400        /* show flight director */
  91. #define HUD_WAYPOINT    0x0800
  92. #define HUD_BTRAIL    0x1000        /* bullet trail history */
  93. #define HUD_CALIBRATED    0x2000        /* calibrated airspeed */
  94. #define HUD_TPOINTER    0x4000        /* target pointer */
  95. #define HUD_VPOINTER    0x8000        /* variable size target pointer */
  96.     Ushort    hud3;
  97. #define    HUD_GVV        0x0001        /* show ghost VV */
  98. #define    HUD_CUE        0x0002
  99. #define    HUD_XVAR    0x0004
  100. #define    HUD_TRUEHEADING    0x0008
  101.     Ushort    hudmode;
  102. #define    HM_LAND        0x0001
  103. #define    HM_NAV        0x0002
  104. #define    HM_DGFT        0x0004
  105. #define    HM_CDIP        0x0008
  106. #define    HM_DECLUTTER    0x0100
  107.     Ushort    hdd;
  108. #define HDD_INSTRUMENTS    0x0001
  109. #define    HDD_NAV        0x0002        /* show nav data */
  110. #define    HDD_COMPASS    0x0004
  111. #define    HDD_SQRCOMPASS    0x0008
  112. #define    HDD_ORTCOMPASS    0x0010
  113.     Ushort    ladder;
  114. #define    LD_FIXED    0x0001        /* ladder fixed on waterline */
  115. #define    LD_RIGHT    0x0002        /* numerals on the right only */
  116. #define    LD_ERECT    0x0004        /* numerals do not roll */
  117. #define    LD_COLOR    0x0008        /* steps are colored */
  118. #define    LD_FUNNEL    0x0010        /* tips are inside */
  119. #define    LD_SLANT    0x0020        /* steps are slanted */
  120. #define    LD_ZENITH    0x0040        /* zenith/nadir symbols */
  121. #define    LD_UNDER    0x0080        /* numerals under the step */
  122. #define    LD_TIP0        0x0100        /* show tip on horizon */
  123. #define    LD_HOLD        0x0200        /* hold ladder  */
  124. #define    LD_HOLDROLL    0x0400        /* hold on heading */
  125. #define    LD_SUN        0x0800        /* show sun symbol */
  126. #define    LD_NEGTIP    0x1000        /* -ve pitch tip inverted */
  127.     Ushort    radar;
  128. #define    R_ON        0x0001
  129. #define    R_LOCK        0x0002
  130. #define    R_INTEL        0x0004
  131. #define    R_INTELCC    0x0008
  132. #define    R_MODE        0x0010
  133. #define    R_MODES        0x0070
  134. #define    R_SHOOT        0x0080
  135. #define    R_SELECT3    0x0100
  136. #define    R_SELECT20    0x0200
  137. #define    R_SELECT5    0x0400
  138.     Ushort    equip;
  139. #define    EQ_GEAR        0x0001        /* gear deployed */
  140. #define    EQ_GEAR1    0x0002        /* true if gear1 has ground contact */
  141. #define    EQ_GEAR2    0x0004
  142. #define    EQ_GEAR3    0x0008
  143. #define    EQ_GEAR4    0x0010
  144. #define    EQ_GEAR5    0x0020
  145.     short    weapon;            /* weapon type */
  146. #define    WE_M61        0x0001
  147. #define    WE_MK82        0x0002
  148. #define    WE_LAST        0x0002
  149. #define    N_WE        5
  150.     short    stores[N_WE];        /* weapons available */
  151. #define MODEL_BASIC    0        /* opt[0] values */
  152. #define MODEL_CLASSIC    1
  153. #define MODEL_XPLANE    2
  154. #define MODEL_YPLANE    3
  155. #define MODEL_FPLANE    4
  156.     Uchar    lamps[25];
  157. #define LAMP_ON        0x01
  158. #define LAMP_BLINK    0x02
  159. #define LAMP_MASK    (LAMP_ON | LAMP_BLINK)
  160. #define LAMP_OK        0x04
  161.  
  162. #define LAMP_GREEN    LAMP_ON
  163. #define LAMP_BGREEN    LAMP_BLINK
  164. #define LAMP_OKGREEN    LAMP_OK
  165. #define LAMP_MGREEN    LAMP_MASK
  166. #define LAMP_REDSHIFT    4
  167. #define LAMP_RED    (LAMP_ON    << LAMP_REDSHIFT)
  168. #define LAMP_BRED    (LAMP_BLINK << LAMP_REDSHIFT)
  169. #define LAMP_OKRED    (LAMP_OK    << LAMP_REDSHIFT)
  170. #define LAMP_MRED    (LAMP_MASK  << LAMP_REDSHIFT)
  171. #define LAMP_ALL    (LAMP_MGREEN | LAMP_MRED)
  172.  
  173. #define LAMP_GLIMIT    0
  174. #define LAMP_STALL    1
  175. #define LAMP_FUEL    2
  176. #define LAMP_GEAR    3
  177. #define LAMP_ALT    4
  178. #define LAMP_PULLUP    5
  179. #define LAMP_DAMAGE    6
  180. #define LAMP_EJECT    7
  181.  
  182. #define LAMP_SET_GREEN(n,s) \
  183.     (EX->lamps[n] = (Uchar)((EX->lamps[n] & ~LAMP_MGREEN) | (s)))
  184. #define LAMP_SET_RED(n,s) \
  185.     (EX->lamps[n] = (Uchar)((EX->lamps[n] & ~LAMP_MRED) \
  186.             | ((s) << LAMP_REDSHIFT)))
  187. #define LAMP_SET_OFF(n) \
  188.     (EX->lamps[n] &= ~LAMP_ALL)
  189.  
  190.     short        hudarea;    /* degrees from center to edge */
  191.     short        hudFontSize;
  192.     short        ils;        /* ils beacon id */
  193.     Ushort        ilsRange;
  194.     ANGLE        ilsHeading;
  195.     short        tapelen;    /* speed/alt scale range */
  196.     short        hudshift;    /* hud y shift */
  197.     short        ldgap;        /* ladder gap size */
  198.     short        ldstep;        /* ladder step size */
  199.     short        ldstep0;    /* ladder step 00 size */
  200.     short        ldstepg;    /* ladder step 00 (gear down) size */
  201.     short        ldtip;        /* ladder tip size */
  202.     short        ldndash;    /* ladder -ve step n-dashes */
  203.     long        fuel;        /* fuel left [*100] */
  204.     short        fuelRate;    /* [*100] */
  205.     short        throttle;    /* position [-100..100]*/
  206.     short        afterburner;    /* position [0..100] */
  207.     short        elevators;    /* position [0..100] */
  208.     short        ailerons;    /* position [-100..100] */
  209.     short        rudder;        /* position [-70..70] */
  210.     short        flaps;        /* position [0..100] */
  211.     short        leFlaps;    /* position [0..100] */
  212.     short        spoilers;    /* position [0..100] */
  213.     short        tElevators;    /* trim position [0..100] */
  214.     short        tRudder;    /* trim position [0..100] */
  215.     short        airbrake;    /* position [0..100] */
  216.     short        brake;        /* position [0..100] */
  217.     short        gear[5];    /* position [0..100] */
  218.     short        power;        /* percent*100 [0..10000] */
  219.     short        thrust;        /* lb_thrust/10 */
  220.     short        Gforce;        /* for display */
  221.     short        maxG;        /* for display */
  222.     short        aoa;        /* for display */
  223.     short        mach;        /* for display */
  224.     VECT        a;        /* acceleration [body] */
  225.     VECT        v;        /* velocity [body] */
  226.     short        StFont;
  227.     Uchar        NEAR*  NEAR* StFontPtr;    /* StFonts[StFont] */
  228.     short        StFontSize;
  229.     OBJECT        *target;    /* aqcuired target */
  230.     long        tid;        /* target id */
  231.     PID        *PIDthrottle;
  232.     PID        *PIDpitch;
  233.     PID        *PIDroll;
  234.     VECT        taccel;        /* target average acceleration */
  235.     VECT        tspeed;        /* target average velocity */
  236.     BTRAIL        *btrail;    /* bullet trail history */
  237.     short        misc[20];    /* autopilot, history etc. */
  238. #define EE(p)        (*(E_PLANE **)&(p)->extra)
  239. #define    LIFETIME(p)    EE(p)->misc[0]    /* millisecs to next randomization */
  240. #define    SPEED(p)    EE(p)->misc[1]    /* desired speed */
  241. #define    HEADING(p)    EE(p)->misc[2]    /* desired heading */
  242. #define    ALTITUDE(p)    EE(p)->misc[3]    /* desired altitude */
  243. #define    NEWTGT(p)    EE(p)->misc[4]
  244. };
  245.  
  246.  
  247. typedef struct e_bomb E_BOMB;
  248. struct e_bomb {
  249.     LVECT        IP;
  250.     long        timpact;
  251. };
  252.  
  253. #define EBM(p)        (*(E_BOMB **)&(p)->extra)
  254.  
  255.  
  256. struct e_parms {
  257.     struct e_parms    *next;
  258.     char    name[10];
  259.  
  260.     long    weight;            /* empty weight [lb] */
  261.     short    Ixx;            /* Ixx as I/Weight in kg-m2/kg */
  262.     short    Iyy;            /* Iyy */
  263.     short    Izz;            /* Izz */
  264.     short    Izx;            /* Izx */
  265.  
  266.     short    liftoff_speed;        /* [kts] */
  267.     short    max_lift;        /* [vm] */
  268.     short    min_lift;        /* [vm] */
  269.     ANGLE    pitch_rate;        /* at 300 knots full elev. [ang/s] */
  270.     ANGLE    roll_rate;        /* at 300 knots full ail. [ang/s] */
  271.     short    eyez;            /* pilot eye above cg [vm] */
  272.     short    eyey;            /* pilot eye forwad of cg [vm] */
  273.     ANGLE    gpitch;            /* pitch on ground [ang] */
  274.     long    ceiling;        /* operational ceiling [ft] */
  275.     short    stores[N_WE];        /* count */
  276.  
  277.     short    brake_mu;        /* friction with brakes applied */
  278.     short    wheel_mu;        /* friction when freewheeling */
  279.  
  280.     short    mil_thrust;        /* [lbf] */
  281.     short    mil_sfc;        /* lb_fuel/(lb_thrust*hour) */
  282.     short    ab_thrust;        /* [lbf] */
  283.     short    ab_sfc;            /* lb_fuel/(lb_thrust*hour) */
  284.     Ushort    fuel_capacity;        /* internal fuel [lb] */
  285.     ANGLE    Ea;            /* Engine rig ang vs. plane [ang] */
  286.     ANGLE    Eb;            /* Engine offset ang vs. plane [ang] */
  287.     short    Er;            /* Engine offset vs. cg [vm] */
  288.  
  289.     short    wing_area;        /* wings area [vm] */
  290.     short    wing_span;        /* tip to tip [vm] */
  291.     short    wing_cord;        /* mean aerodynamic cord [vm] */
  292.     short    ACy;            /* wing ac forward of cg [vm] */
  293.     short    ACz;            /* wing ac upward of cg [vm] */
  294.     ANGLE    Aoffset;        /* Wing rigging angle vs. plane [ang] */
  295.     ANGLE    Cl0;            /* alpha where Cl=0 [ang] */
  296.     short    maxCl;            /* max Cl for wing foil */
  297.     short    minCl;            /* min Cl for wing foil */
  298.     short    FEff;            /* flaps effective alpha/flaps */
  299.     short    FEffCl;            /* flaps Clmax rate/DegFlaps */
  300.     short    lefEffCl;        /* Clmax/LE flaps deg */
  301.     short    efficiency_factor;    /* Oswald's efficiency factor */
  302.     short    Cm0w;            /* wing foil Cm at 0 alpha */
  303.  
  304.     short    tail_area;        /* [vm] */
  305.     short    tail_span;        /* [vm] */
  306.     short    TACy;            /* tail ac forward of cg [vm] */
  307.     short    TACz;            /* tail ac upward of cg [vm] */
  308.     ANGLE    Toffset;        /* Tail rigging angle vs. wing [ang] */
  309.     short    Tvol;            /* tail volume */
  310.     short    TmaxCl;            /* max Cl for tail foil */
  311.     short    TminCl;            /* min Cl for tail foil */
  312.  
  313.     short    rudd_area;        /* [vm] */
  314.     short    rudd_span;        /* [vm] */
  315.     short    RACy;            /* rudder ac forward of cg [vm] */
  316.     short    RACz;            /* rudder ac upward of cg [vm] */
  317.     short    RmaxCl;            /* max Cl for rudder foil */
  318.  
  319.     short    Cdp0;            /* parasitic drag: profile */
  320.     short    Cds;            /* parasitic drag: speed brakes */
  321.     short    Cdg;            /* parasitic drag: gear */
  322.     short    CdMK82;            /* parasitic drag: each MK82 */
  323.  
  324.     ANGLE    MaxFlaps;        /* max flaps [ang] */
  325.     ANGLE    MaxLEFlaps;        /* max LE flaps [ang] */
  326.     ANGLE    MaxSpoilers;        /* max spoilers [ang] */
  327.     ANGLE    MaxElevators;        /* max elevators [ang] */
  328.     ANGLE    MaxAilerons;        /* max ailerons [ang] */
  329.     ANGLE    MaxRudder;        /* max rudder [ang] */
  330.  
  331.     ANGLE    AFamin;            /* AutoFlaps: min aoa to engage */
  332.     short    AFrate;            /* AutoFlaps: flaps/aoa rate */
  333.     ANGLE    AFmax;            /* AutoFlaps: max flaps authority [%] */
  334.  
  335.     ANGLE    ALEFamin;        /* AutoLEFlaps: min aoa to engage */
  336.     short    ALEFrate;        /* AutoLEFlaps: leFlaps/aoa rate */
  337.  
  338.     short    AErate;            /* AutoElevators: speed factor */
  339.  
  340.     short    APrate;            /* AutoPedals: speed factor */
  341.  
  342.     short    Cydr;            /* rudder sideforce */
  343.     short    Cybeta;            /* vx damping */
  344.  
  345.     short    Cm0;            /* total Cm at 0 alpha */
  346.     short    Cmde;            /* elevators effectiveness */
  347.     short    Cmq;            /* pitch damping */
  348.     short    Cmalpha;        /* alpha (stabilizer) induced pitch */
  349.     short    Cmalphadot;        /* alpha rate induced pitch */
  350.  
  351.     short    Clda;            /* aileron effectiveness */
  352.     short    Clp;            /* roll damping */
  353.     short    Clbeta;            /* dihedral effect */
  354.     short    Cldr;            /* roll from rudder */
  355.  
  356.     short    Cndr;            /* rudder effectiveness */
  357.     short    Cnr;            /* yaw damping */
  358.     short    Cnbeta;            /* weathercock stability */
  359.     short    Cnda;            /* ailerons induced yaw */
  360.     short    Cnp;            /* roll induced yaw */
  361.  
  362.     short    hudtype;        /* HUD_F16 etc. */
  363.  
  364.     short    opt[10];        /* options */
  365.     PID    PIDthrottle;
  366.     PID    PIDpitch;
  367.     PID    PIDroll;
  368.     struct gear {        /* gear tip position relative to cg */
  369.         short    x;        /* + means right */
  370.         short    y;        /* + means forward */
  371.         short    z;        /* - means down */
  372.         short    dgmax;        /* max strut deflection */
  373.         short    dtp;        /* tyre deflection at P */
  374.         short    P;        /* strut precharge force */
  375.         short    Cv;        /* strut damping coeff. */
  376.         ANGLE    emax;        /* Steering angle at full pedals. */
  377.         short    ur;        /* rolling friction coeff. */
  378.         short    ub;        /* full brake friction coeff. */
  379.         short    us;        /* sideslip friction coeff. */
  380.         short    rateup;        /* percent/sec raise rate */
  381.         short    ratedn;        /* percent/sec lower rate */
  382.     } gear[5];
  383. };
  384.  
  385. #define EEP(p)    EE(p)->parms
  386. #define EP    EEP(p)
  387.  
  388. #ifndef EX
  389. #define EX    EE(p)
  390. #endif
  391.  
  392. /* autop.c */
  393. extern void    FAR SetKillCorrection (OBJECT *p, OBJECT *target, VECT R,
  394.     int *tti);
  395. extern void    FAR dynamics_auto (OBJECT *p);
  396.  
  397. /* engine.c */
  398. extern void    FAR f16engine (OBJECT *p, short sos);
  399.  
  400. /* gear.c */
  401. extern void    FAR LandGear (OBJECT *p, VECT F, VECT MM);
  402. extern void    FAR LandGearDamp (OBJECT *p);
  403.  
  404. /* oplane.c */
  405. #define DDshow(p,n,t,v)    if (CC==(p)) fDDshow (n, t, v)
  406. #define CCshow(p,n,t,v)    if (CC==(p)&&(st.flags&SF_DEBUG)) fCCshow (n, t, v)
  407. #define CFshow(p,t,v)    if (CC==(p)&&(st.flags&SF_DEBUG)) fCFshow (t, v)
  408. #define CAshow(p,t,v)    if (CC==(p)&&(st.flags&SF_DEBUG)) fCAshow (t, v)
  409. #define CVshow(p,t,v)    if (CC==(p)&&(st.flags&SF_DEBUG)) fCVshow (t, v)
  410.  
  411. extern void    FASTCALL FAR fDDshow (int frac, char *title, long value);
  412. extern void    FASTCALL FAR fCCshow (int frac, char *title, long value);
  413. extern void    FASTCALL FAR fCFshow (char *title, int value);
  414. extern void    FASTCALL FAR fCAshow (char *title, int value);
  415. extern void    FASTCALL FAR fCVshow (char *title, int value);
  416.  
  417. extern void    FAR CCnote (OBJECT *p, char *note);
  418. extern void    FAR CCland (OBJECT *p);
  419. extern void    FAR CCfly  (OBJECT *p);
  420. extern int    FAR check_land (OBJECT *p);
  421. extern int    FAR check_takeoff (OBJECT *p);
  422. extern void    FAR supply (OBJECT *p, int mode);
  423. extern void    FAR dampen (short *old, int new, int factor);
  424. extern int    FAR on_runway (OBJECT *p);
  425. extern int    FAR dynamics_input (OBJECT *p);
  426.  
  427. /* om61.c */
  428. #define    BULLETV        (1000*VONE)
  429. #define    BULLETSCATTER    (D90/180)
  430. extern int    FAR BulletSpeed (OBJECT *p, VECT V);
  431.  
  432. /* omk82.c */
  433. extern int    FAR BombSpeed (OBJECT *p, VECT V);
  434. extern int    FAR BombIP (LVECT R, VECT V, long tz, LVECT IP);
  435.  
  436. /* prm.c */
  437. extern void     (FAR* FAR flight_models[])(OBJECT *p, int action);
  438. extern struct e_parms * FAR parms_get (char *pname);
  439. extern void    FAR parms_free (void);
  440.  
  441. /* sixdof.c */
  442. extern void    FAR SixDOF (OBJECT *p, VECT F, VECT MM, MAT I);
  443.  
  444. #endif
  445.